package main

import (
	"github.com/micro/go-log"
	"github.com/micro/go-micro"
	"git.oschina.net/fanbuchi/xgggh/redbags/subscriber"

	redbags "git.oschina.net/fanbuchi/xgggh/redbags/proto/redbags"
	"git.oschina.net/fanbuchi/xgggh/redbags/handler"
)

func main() {
	// New Service
	service := micro.NewService(
		micro.Name("com.xgggh.srv.redbags"),
		micro.Version("latest"),
	)

	// Initialise service
	service.Init()

	// Register Handler
	redbags.RegisterRedBagsHandler(service.Server(), new(handler.RedBags))

	// Register Struct as Subscriber
	micro.RegisterSubscriber("com.xgggh.srv.redbags", service.Server(), new(subscriber.RedBags))

	// Register Function as Subscriber
	micro.RegisterSubscriber("com.xgggh.srv.redbags", service.Server(), subscriber.Handler)

	// Run service
	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}
